package com.atguigu.tingshu.user.service.impl;

import com.atguigu.tingshu.common.result.ResultCodeEnum;
import com.atguigu.tingshu.common.utils.ThrowUtil;
import com.atguigu.tingshu.model.user.VipServiceConfig;
import com.atguigu.tingshu.user.mapper.VipServiceConfigMapper;
import com.atguigu.tingshu.user.service.VipServiceConfigService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Slf4j
@Service
@SuppressWarnings({ "all" })
public class VipServiceConfigServiceImpl extends ServiceImpl<VipServiceConfigMapper, VipServiceConfig>
        implements VipServiceConfigService {

    @Autowired
    private VipServiceConfigMapper vipServiceConfigMapper;

    @Override
    public List<VipServiceConfig> findAll() {
        log.info("查询全部VIP配置");
        List<VipServiceConfig> list = vipServiceConfigMapper.selectList(null);
        log.info("查询到VIP配置数量: {}", list.size());
        return list;
    }

    @Override
    public VipServiceConfig getVipServiceConfigById(Long id) {
        log.info("根据ID查询VIP套餐详情 - id: {}", id);
        VipServiceConfig vipServiceConfig = vipServiceConfigMapper.selectById(id);
        ThrowUtil.throwIf(vipServiceConfig == null, ResultCodeEnum.DATA_ERROR, "VIP套餐不存在");
        log.info("查询VIP套餐详情成功 - id: {}, name: {}", id, vipServiceConfig.getName());
        return vipServiceConfig;
    }

}
